package TCP;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",9090);

        OutputStream os = socket.getOutputStream();
        DataOutputStream dos = new DataOutputStream(os);
        InputStream is = socket.getInputStream();
        DataInputStream dis = new DataInputStream(is);
        Scanner scanner = new Scanner(System.in);
        while (true){
            System.out.println("请输入:");
            String str = scanner.nextLine();

            if ("exit".equals(str)){
                System.out.println("退出成功!!!!");
                dis.close();
                os.close();
                socket.close();
                break;
            }
            dos.writeUTF(str);
            dos.flush();

            String ret = dis.readUTF();
            System.out.println(ret);
        }
    }
}
